package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.OrderDetail;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderDetailMapper {


    /**
     * 往订单详情表中插入多条数据
     *
     * @param orderDetailList 订单商品数据集合
     */
    void insertBatch(List<OrderDetail> orderDetailList);

    /**
     * 历史订单查询
     * @param dto dto
     * @return 订单集合
     */
    Page<OrderVO> queryingHistoryOrders(OrdersPageQueryDTO dto);


    /**
     * 根据orderId删除订单商品数据
     * @param id orderId
     */
    @Delete("delete from order_detail where order_id =#{id}")
    void deleteByOrderId(Long id);

    /**
     * 根据订单id查询该订单商品详情
     * @param id 订单id
     * @return 商品数据集合
     */
    @Select("select  * from order_detail where order_id =#{id}")
    List<OrderDetail> selectByOrderId(Long id);
}